#include <stdio.h>
#include <unistd.h>
#include <stdlib.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <string.h>

int main()
{
    pid_t pid = fork();
    
    if(0 == pid) {
        sleep(1);   // 此时子进程会成为 孤儿进程
        printf("child pid = %d, ppid = %d\n", getpid(), getppid());
    } else if(pid > 0) {
        printf("----> parent\n");
        printf("parent pid = %d, ppid = %d\n", getpid(), getppid());
    }

    return 0;
}

